package com.yupi.springbootinit.controller;

import com.yupi.springbootinit.common.BaseResponse;
import com.yupi.springbootinit.model.dto.autoCommit.AutoCommitRequest;
import com.yupi.springbootinit.service.AutoCommitService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/auto")
@Slf4j
public class AutoCommitController {
    @Resource
    private AutoCommitService commitService;
    @GetMapping("/commit")
    public BaseResponse commitWithCustomId(@RequestParam String id) {
        return commitService.autoCommit(new AutoCommitRequest(id));
    }

    @PostMapping("/commits")
    public BaseResponse commits(@RequestBody AutoCommitRequest request) {
        return commitService.autoCommit(request);
    }
}
